/**
 * 视频生成路由模块
 * @module videoRoutes
 */
const express = require('express');
const router = express.Router();
const videoController = require('../controllers/videoController');
const imgController = require('../controllers/imgController');

console.log('🌐 视频路由初始化中...');

// 增强日志中间件
router.use((req, res, next) => {
    console.log(`请求路径: ${req.method} ${req.originalUrl}`);
    console.log('请求体:', JSON.stringify(req.body, null, 2)); // 添加请求体日志
    next();
});






/**
 * @swagger
 * /api/video/textAndImgAndAudioToVideo:
 *   post:
 *     summary: 文字、图片和音频生成视频
 *     description: 根据提供的文字、图片和音频生成视频
 *     tags: [视频生成]
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             $ref: '#/components/schemas/VideoRequest'
 *     responses:
 *       200:
 *         description: 视频生成成功
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/VideoResponse'
 *       400:
 *         description: 参数错误
 *       500:
 *         description: 服务器内部错误
 */
router.post('/video/textAndImgAndAudioToVideo', videoController.textAndImgAndAudioToVideo);


/**
 * @swagger
 * tags:
 *   name: 视频生成
 *   description: 视频生成相关接口
 */

/**
 * @swagger
 * /api/video/textAndImageToVideo:
 *   post:
 *     summary: 文字和图片生成视频
 *     description: 根据提供的文字和图片生成视频
 *     tags: [视频生成]
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             $ref: '#/components/schemas/VideoRequest'
 *     responses:
 *       200:
 *         description: 视频生成成功
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/VideoResponse'
 *       400:
 *         description: 参数错误
 *       500:
 *         description: 服务器内部错误
 */
router.post('/video/textAndImageToVideo', videoController.textAndImageToVideo);

/**
 * @swagger
 * /api/img/getNewsPoster:
 *   post:
 *     summary: 生成海报
 *     description: 根据提供的图片和配置生成海报
 *     tags: [图片生成]
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             $ref: '#/components/schemas/PosterRequest'
 *     responses:
 *       200:
 *         description: 海报生成成功
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/PosterResponse'
 *       400:
 *         description: 参数错误
 *       500:
 *         description: 服务器内部错误
 */
router.post('/img/getNewsPoster', imgController.getNewsPoster);

console.log('已注册路由: POST /video');
console.log('已注册路由: POST /img');

module.exports = router;